package com.example.myapp;



import android.os.Bundle;
import android.os.FileObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;


public class DemoFragment2 extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        inflater=LayoutInflater.from(container.getContext());
        View rootview=inflater.inflate(R.layout.fragment_demo2,container,false);//将布局转换成对象
        Button bt=(Button)rootview.findViewById(R.id.bt);
        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getActivity(), "我是分类", Toast.LENGTH_SHORT).show();
            }
        });
        return rootview;
    }
}
